package com.example.springboot09.桥接模式;

/**
 * @ClassName 桥接模式
 * @Description TODO
 * @Author tianqinglong
 * @Date 17:09 2022/7/25
 * @Version 1.0
 **/
public class 桥接模式 {
}
//品牌
interface Brand {
    void info();
}
//联想品牌
class Lenovo implements Brand{
    @Override
    public void info() {
        System.out.print("联想");
    }
}
//苹果品牌
 class Apple implements Brand{

    @Override
    public void info() {
        System.out.print("苹果");
    }
}
abstract class Computer {
    //组合 品牌
    protected Brand brand;

    public Computer(Brand brand) {
        this.brand = brand;
    }

    public void info(){
        brand.info();//自带品牌
    }
}
class Desktop extends Computer{
    public Desktop(Brand brand) {
        super(brand);
    }
    @Override
    public void info() {
        super.info();
        System.out.print("台式机");
    }
}

class Laptop extends Computer{

    public Laptop(Brand brand) {
        super(brand);
    }

    @Override
    public void info() {
        super.info();
        System.out.print("笔记本");
    }


    public static void main(String[] args) {
        //苹果笔记本
        Computer computer = new Laptop(new Apple());
        computer.info();
        System.out.println();
        //联想台式机
        Computer computer2 = new Desktop(new Lenovo());
        computer2.info();
    }
}
